home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Environments / PowerFantasm™ 4.19a / PowerFantasm™ / Fantasm V4 headers / LS_68K_Macros.def < prev    next >
Text File  |  1996-06-21  |  3KB  |  137 lines

  1. *************************************************************************
  2. *LIGHTSOFT STANDARD MACROS                                              *
  3. *************************************************************************
  4. **Calls mixedmode to switch from 68k to ppc. 
  5. **When you enter your PPC routine, you should save the contents of LR as it has
  6. **your return address.
  7. **To return from your PPC routine load LR with the return address (as above) and execute
  8. **a "blr" instruction, which will return you to the 68k emulator.
  9. **You should save and restore r0,r1,r10,r31,lr,ctr in your routine
  10. **Usage:
  11. *    go_ppc
  12. *    proc_ppc
  13. *    your ppc code
  14. *    blr    *back to 68k
  15. *Go_ppc does not support parameter passing. See IM PPC system s/w for info on how to
  16. *modify the universal proc pointer (at univ_pointer\@) to handle params.
  17. Go_PPC:    macro
  18.     proc_68k
  19.     lea    ppc_routine\@(pc),a0    *address of routine to run
  20.     lea    my_tv\@(pc),a1
  21.     move.l    a0,(a1)        *pointer to routine in tv
  22.     lea    proc_pointer\@(pc),a0
  23.     move.l    a1,(a0)        *put tv in header header
  24.     lea    univ_pointer\@(pc),a0
  25.     jsr    (a0)            *into mixedmodemagic
  26.     rts_    "Go_PPC_MACRO"
  27.     align    4    
  28. my_tv\@:    ds.l    2
  29.  
  30.  
  31. ***Mode switch code to PPC
  32. univ_pointer\@:
  33.     dc.w    $aafe        *mixedmodemagic trap
  34.     dc.b    7        *version of mixed mode
  35.     dc.b    0        *selectors (not used here)
  36.     dc.l    0        *res1
  37.     dc.b    0        *res2
  38.     dc.b    0        *selector info
  39.     dc.w    0        *number of routines (array index!)
  40. **Procinforec
  41.     dc.l    0        *procinfo 0=no parameters, see IM PPC sys s/w
  42.     dc.b    0        *resvd
  43.     dc.b    1        *ppc (68k=0)
  44.     dc.w    4        *Routine flags 4=native + 2=needs init + 1=offset
  45.  
  46. proc_pointer\@:
  47.     ds.l    1        *proc pointer (to transition vector actually!)
  48.     dc.l    0        *resvd
  49.     dc.l    0        *resvd
  50.  
  51. **The PPC routine
  52.     align    8
  53. ppc_routine\@:
  54.     endm
  55.  
  56. *************************************************************
  57. **Insert a macsbug label
  58. **call as rts_ "label_string"
  59.  
  60. rts_:    MACRO
  61.     rts
  62.     dc.b    $80+end\@-start\@
  63. start\@:    dc.b    \1
  64. end\@:    
  65.     even
  66.     dc.w    0    *literals
  67.     endm
  68.  
  69. * -------------------------------
  70. * please note: I'm not going mad, I just need a simple life.....
  71.  
  72. bnz:        MACRO
  73.         bne    \1
  74.         ENDM
  75.         
  76. bz:        MACRO
  77.         beq    \1
  78.         ENDM
  79.  
  80. * -------------------------------
  81.  
  82. mystack    reg    a7
  83.  
  84. * -------------------------------
  85. PUSH:           MACRO
  86.                 move.l  \1,-(`mystack)
  87.                 ENDM
  88. * ------------------------------
  89. POP:            MACRO
  90.                 move.l  (`mystack)+,\1
  91.                 ENDM
  92. * -------------------------------
  93. POPPUSH:        MACRO
  94.                 move.l  (`mystack),\1
  95.                 ENDM
  96.  
  97. *************************************************************
  98. **INC ADDS 1 TO A SELECTED REGISTER.
  99. **TAKES SIZE AND REGISTER FROM PARAMETERS
  100. INC:    MACRO
  101.     IFC    "","\1"
  102.     FAIL
  103.     ENDC
  104.     ADDq.\0    #1,\1
  105.     ENDM
  106.     
  107. *************************************************************
  108. **DEC SUBS 1 FROM A SELECTED REGISTER
  109. **TAKES SIZE AND REGISTER FROM PARAMETERS
  110. DEC:    MACRO
  111.     IFC    "","\1"
  112.     FAIL
  113.     ENDC
  114.     SUBQ.\0    #1,\1
  115.     ENDM
  116.     
  117. *************************************************************
  118. **SAVE_ALL SAVES D0-D7/A0-A6 ON STACK
  119. SAVE_ALL:    MACRO
  120.     MOVEM.L    D0-D7/A0-A6,-(SP)
  121.     ENDM
  122.  
  123. *************************************************************
  124. **RESTORE_ALL GETS D0-D7/A0-A6 OFF STACK
  125. RESTORE_ALL:    MACRO
  126.     MOVEM.L    (SP)+,D0-D7/A0-A6
  127.     ENDM
  128.     
  129. *************************************************************
  130. push_a0:    macro
  131.     move.l    a0,-(sp)
  132.     endm
  133. *************************************************************
  134. pop_a0:    macro
  135.     move.l    (sp)+,a0
  136.     endm
  137.